<?php
/**
 * Created by PhpStorm.
 * User: zhan
 * Date: 2018/10/10  10:18
 */
namespace app\admin\controller;

class Member extends Common
{
    private $table_admin;
    /*
	*	构造函数
	*/
    function __construct(){
        parent::__construct();
        $this->table_admin = db('member');
    }

    //会员列表
    public function lists(){
        $pageParam = ['query' =>[]];
        $where = [];

        $email =input("email");
        if($email!=''){
            $where['email']=$email;
            $pageParam['query']['email'] = $email;
        }
        $this->assign('email', $email);

        $keyword = input("keyword");
        if($keyword != ''){
            $where['nickname|mobile']=array("like",'%'.input('keyword').'%');
            $pageParam['query']['keyword'] = $keyword;
        }
        $this->assign('keyword', $keyword);

        $list = $this->table_admin->where($where)->order('id desc')->paginate(15, false, $pageParam);
        $page = $list->render();
        $this->assign('page',$page);
        $this->assign('users',$list);
        return $this->fetch();
    }


    //详情
    public function detail()
    {
        $id  = input('id');
        $data = $this->table_admin->where(['id'=>$id])->find();
        if(empty($data))return $this->error('数据不存在');
        $this->assign('da', $data);
        return $this->fetch();
    }

}